   function operResult(operResult){
       if(operResult == 1) {
            return '成功';
        }else if(operResult == 2) {
            return '失败';
        }else if(operResult == 3) {
            return '部分成功';
        }
    }
    function pageInit(){
        var parentHeight,parentWidth;
        parentHeight = $("#pending-table").height()*1 - 23,
        parentWidth = $("#pending-table").width()*1 + 14;
        //创建jqGrid组件
        jQuery("#pendingList").jqGrid({
            url: contextPath + "/OperLog/queryOperLogJqg",
            datatype: "json",
            height: parentHeight,
            width: parentWidth,
            colNames:['操作时间','操作人员','操作项','操作模块','详细信息','操作结果'],
            colModel:[
                    {name:'operateTime',index:'operateTime', sortable: false},
                    {name:'operateUser',index:'operateUser', sortable: false},
                    {name:'commandName',index:'commandName', sortable: false},
                    {name:'moduleName',index:'moduleName', sortable: false},
                    {name:'detail',index:'detail', sortable: false},
                    {name:'result',index:'result', sortable: false,formatter: operResult}
            ],
            sortname:'id',
            sortorder:'desc',
            viewrecords: true,
            rowNum: 20,
            rowList:[20,50,100],
            pager:"#gridpager"
        });
        /*创建jqGrid的操作按钮容器*/
        jQuery("#pendingList").jqGrid('navGrid', '#gridpager', {edit: false,add: false, del:false,search: false});
    }; 
    //函数：获取尺寸
    var timer = 0;
    $(window).resize(function(){
        clearTimeout(timer);
        timer = setTimeout(function() {
            $("#pendingList").setGridWidth($('#pending-table').width() + 12);
            $("#pendingList").setGridHeight($('#pending-table').height() - 23);
        }, 260);
    });
    // 侧边栏缩小时，实时的给jqgrid的宽和高赋值
    $("#asidebarSwitch").on('click',function() {
        var time = 0;
        var set = setInterval(function (){
            $("#pendingList").setGridWidth($('#pending-table').width()*1 + 14);　　
            $("#pendingList").setGridHeight($('#pending-table').height()*1 - 23);
            time++;
            if(time == 201){
                clearInterval(set);
            }
        },time);
    });

// 查询操作人员
    $.ajax({
        url: contextPath + "/user/queryuserlistNew",
        type: 'GET',
        dataType: "json",
        contentType: "application/json",
        success: function(data){
            var str = '<option value="" selected>选择操作人员</option>';
            for (var i =0 ,len = data.length; i < len; i++) {
            	str += '<option value="' + data[i].username + '">' + data[i].username + "</option>";
            }
            $("#operUser").html(str);
        },
        error: function(data){
            toastr.error(data.message, "请求失败");
        }
    });
    // 查询操作项
    $.ajax({
        url: contextPath + "/OperLog/getAllOperItems",
        type: 'GET',
        dataType: "json",
        contentType: "application/json",
        success: function(data){
            var str = '<option value="" selected>选择操作项</option>';
            for (var i =0 ,len = data.length; i < len; i++) {
            	str += '<option value="' + data[i].command + '">' + data[i].commandName + "</option>";
            }
            $("#operAuthorityID").html(str);
        },
        error: function(data){
            toastr.error(data.message, "请求失败");
        }
    });
    // 查询操作模块
    $.ajax({
        url: contextPath + "/OperLog/getAllModules",
        type: 'GET',
        dataType: "json",
        contentType: "application/json",
        success: function(data){
            var str = '<option value="" selected>选择操作模块</option>';
            for (var i =0 ,len = data.length; i < len; i++) {
            	str += '<option value="' + data[i].moduleName + '">' + data[i].moduleName + "</option>";
            }
            $("#operModelID").html(str);
        },
        error: function(data){
            toastr.error(data.message, "请求失败");
        }
    });

    // 查询
    $('#query').on('click',function(){
        var operUser = $("#operUser").val();
        var operAuthorityID = $("#operAuthorityID").val();
        var operModelID = $("#operModelID").val();
        var operResult = $("#operResult").val();
        $("#pendingList").setGridParam({
            url : contextPath + "/OperLog/queryOperLogJqg",
            postData : {
                queryCond: {
                	operateUser: operUser,
                	command: operAuthorityID,
                	moduleName: operModelID,
                	result: operResult
                }
            },
            page: 1
        }).trigger("reloadGrid");
    });

   // 导出
   $('#export').on('click',function(){
       var operUser = $("#operUser").val();
       var operAuthorityID = $("#operAuthorityID").val();
       var operModelID = $("#operModelID").val();
       var operResult = $("#operResult").val();

       var obj = new Object();
       obj.operateUser = operUser;
       obj.operAuthorityID = operAuthorityID;
       obj.operModelID = operModelID;
       obj.operResult = operResult;

       var url = buildURL("OperLog/exportOperLog",obj);
       window.open(url);
   });

   function buildURL(url,param/*链接和参数*/){
       var paramStr = '';
       $.each(param,function(key,item){
           var link = '&' + key + "=" + item;
           paramStr += link;
       })
       paramStr = url + "?" + paramStr.substr(1);
       return paramStr.replace(' ','');
   }

   // 审核
    // 获取子任务数据
    $("#pendingList").on('click','.check,.dispose',function(){
        var id = $(this).parent().parent().attr('id');
        var subTaskData = $("#pendingList").jqGrid('getRowData',id);
        console.log(subTaskData.subTaskId);
        $.cookie('subTaskId',JSON.stringify(subTaskData.subTaskId));
    });